package com.xm.settlement.controller;

import com.xm.settlement.commons.base.BaseController;
import com.xm.settlement.commons.utils.PageInfo;
import com.xm.settlement.service.IAppCashLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/3/14.
 */
@Controller
@RequestMapping("/appCashLog")
public class AppCashLogController extends BaseController{

    @Autowired
    private IAppCashLogService appCashLogService;

    /**
     * 提现审核主页
     *
     * @return
     */
    @GetMapping(value = "/manager")
    public String Manager() {
        return "settlement/appBase/appCashLog";
    }

    /**
     * 提现审核管理
     * @param page
     * @param rows
     * @param sort
     * @param order
     * @return
     */
    @PostMapping("/dataGrid")
    @ResponseBody
    public Object dataGrid(Integer page, Integer rows, String sort, String order) {
        PageInfo pageInfo = new PageInfo (page, rows, sort, order);
        Long createId = getUserId();
        Map<String, Object> condition = new HashMap<String, Object>();
        condition.put("createId",createId);
        pageInfo.setCondition(condition);
        appCashLogService.selectDataGrid(pageInfo,createId);
        return pageInfo;
    }


    /**
     * 改变审核状态
     *
     * @param
     * @return
     */
    @RequestMapping("/agree")
    @ResponseBody
    public Object edit(Long id) {
        appCashLogService.updateStatus(id);
        return  renderSuccess("审核通过");
    }


    /** 添加审核未通过原因 */
    @RequestMapping("/refuse")
    @ResponseBody
    public void insertRemarkById(Long id,String remark){
        HashMap<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("remark",remark);
        appCashLogService.insertRemarkById(map);
    }
}
